home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 20 Februrary 1996
- //
-
- //
- // Procedure Name:
- // playButtonStart, playButtonStepBackward, playButtonBackward
- // playButtonStop, playButtonRecord, playButtonForward
- // playButtonStepForward, playButtonEnd
- //
- // Description:
- // Procs that update the current time according to which
- // playback control is pressed.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- global proc playButtonStart() {
- currentTime -edit `playbackOptions -query -min`;
- }
-
- global proc playButtonStepBackward() {
- float $by = `playbackOptions -query -by`;
- float $curr = `currentTime -query`;
- float $min = `playbackOptions -query -min`;
- float $max = `playbackOptions -query -max`;
-
- if(( $curr != $min )
- &&(( $curr - $by ) >= $min )
- &&(( $curr - $by ) < $max ))
- {
- currentTime -edit ( $curr - $by );
- }
- else {
- currentTime -edit $max;
- }
- }
-
- global proc playButtonBackward() {
- int $isOscillate = (`playbackOptions -q -loop` == "oscillate");
-
- if(( `play -query -state` == 1 )
- &&(( `play -query -forward` == 0 ) || $isOscillate ))
- {
- play -state off;
- }
- else {
- float $by = `playbackOptions -query -by`;
- if( `currentTime -q` - $by < `playbackOptions -q -min` ) {
- currentTime -e `playbackOptions -q -max`;
- }
-
- global string $gTimeSliderTimeField;
- global string $gPlayBackForwardButton;
- global string $gPlayBackReverseButton;
-
- // We do this here since the callback that sets up the
- // images on the buttons won't get called if we're already
- // playing back (forward) and hit the "backward" button;
- // The "playingBack" condition will not have been changed!
- //
- symbolButton -edit
- -image "timeplay.xpm"
- -annotation "Play forwards. Pressing the ESC key will stop playback." $gPlayBackForwardButton;
- symbolButton -edit
- -image "timestop.xpm"
- -annotation "Stop playback. Pressing the ESC key will also stop playback." $gPlayBackReverseButton;
- floatField -e -enable false $gTimeSliderTimeField;
-
- play -forward off;
- }
- }
- global proc playButtonForward() {
- global string $gTimeSliderTimeField;
-
- int $isOscillate = (`playbackOptions -q -loop` == "oscillate");
-
- if(( `play -query -state` == 1 )
- &&(( `play -query -forward` == 1 ) || $isOscillate ))
- {
- play -state off;
- }
- else {
- float $by = `playbackOptions -query -by`;
- if( `currentTime -q` + $by > `playbackOptions -q -max` ) {
- currentTime -e `playbackOptions -q -min`;
- }
-
- global string $gPlayBackForwardButton;
- global string $gPlayBackReverseButton;
- global string $gPlayBackSlider;
-
- // We do this here since the callback that sets up the
- // images on the buttons won't get called if we're already
- // playing back (forward) and hit the "backward" button;
- // The "playingBack" condition will not have been changed!
- //
- symbolButton -edit
- -image "timestop.xpm"
- -annotation "Stop playback. Pressing the ESC key will also stop playback." $gPlayBackForwardButton;
- symbolButton -edit
- -image "timerev.xpm"
- -annotation "Play backwards. Pressing the ESC key will stop playback." $gPlayBackReverseButton;
- floatField -e -enable false $gTimeSliderTimeField;
-
- play -forward on -sound `timeControl -q -s $gPlayBackSlider`;
- }
- }
-
- global proc playButtonStepForward() {
- float $by = `playbackOptions -query -by`;
- float $curr = `currentTime -query`;
- float $min = `playbackOptions -query -min`;
- float $max = `playbackOptions -query -max`;
-
- if(( $curr != $max )
- &&(( $curr + $by ) <= $max )
- &&(( $curr + $by ) > $min ))
- {
- currentTime -edit ( $curr + $by );
- }
- else {
- currentTime -edit $min;
- }
- }
-
- global proc playButtonEnd() {
- currentTime -edit `playbackOptions -query -max`;
- }
-
- global proc int playbackStateChanged() {
- global string $gPlayBackForwardButton;
- global string $gPlayBackReverseButton;
- global string $gTimeSliderTimeField;
-
- if( `isTrue playingBack` ) {
- if(( `play -query -st` == 0) || `play -query -forward` == 1 ) {
-
- if( `symbolButton -exists $gPlayBackForwardButton` ) {
- symbolButton -edit
- -image "timestop.xpm"
- -annotation "Stop playback. Pressing the ESC key will also stop playback." $gPlayBackForwardButton;
- }
-
- if( `symbolButton -exists $gPlayBackReverseButton` ) {
- symbolButton -edit
- -image "timerev.xpm"
- -annotation "Play backwards. Pressing the ESC key will stop playback." $gPlayBackReverseButton;
- }
- }
- else {
- if( `symbolButton -exists $gPlayBackForwardButton` ) {
- symbolButton -edit
- -image "timeplay.xpm"
- -annotation "Play forwards. Pressing the ESC key will stop playback." $gPlayBackForwardButton;
- }
-
- if( `symbolButton -exists $gPlayBackReverseButton` ) {
- symbolButton -edit
- -image "timestop.xpm"
- -annotation "Stop playback. Pressing the ESC key will also stop playback." $gPlayBackReverseButton;
- }
- }
-
- if( `floatField -exists $gTimeSliderTimeField` ) {
- floatField -e -enable false $gTimeSliderTimeField;
- }
- }
- else {
- if( `symbolButton -exists $gPlayBackForwardButton` ) {
- symbolButton -edit
- -image "timeplay.xpm"
- -annotation "Play forwards. Pressing the ESC key will stop playback." $gPlayBackForwardButton;
- }
-
- if( `symbolButton -exists $gPlayBackReverseButton` ) {
- symbolButton -edit
- -image "timerev.xpm"
- -annotation "Play backwards. Pressing the ESC key will stop playback." $gPlayBackReverseButton;
- }
-
- if( `floatField -exists $gTimeSliderTimeField` ) {
- floatField -e -enable true $gTimeSliderTimeField;
- }
- }
-
- // Scripts attached to the "condition" command
- // must return an int.
- //
- return 1;
- }
-
- // Procedure Name:
- // timeSlider
- //
- // Description:
- // This implements the group of controls that represents the
- // timeSlider. The timeSlider can either be part of a window
- // or in a window of its own.
- //
- // Input Arguments:
- // The name of the layout that the timeSlider should add itself
- // to. If empty, then this script will create a window.
- //
- // Return Value:
- // The name of the top level layout control.
- // (Used for embedding within another window)
- //
- //global proc string timeSlider(string $parentName)
- {
- global string $gTimeSliderForm;
- global string $gPlayBackForwardButton;
- global string $gPlayBackReverseButton;
- global string $gPlayBackSlider;
- global string $gTimeSliderTimeField;
-
- // Create a layout appropriate for the Time slider.
- //
- string $timeSlider = `formLayout -parent $gTimeSliderForm`;
-
- // Create a frame layout for the Time slider control.
- //
- string $timeFrame = `frameLayout
- -parent $timeSlider
- -borderVisible true
- -borderStyle "in"
- -labelVisible false
- -collapse false
- -collapsable false`;
-
- // Create the Time slider control.
- //
- $gPlayBackSlider = `timeControl -parent $timeFrame -height 26`;
-
- setParent $timeSlider;
-
- // Create the Time field.
- //
- $gTimeSliderTimeField = `floatField
- -annotation "Current Time: Set the current time"
- -width 70
- -precision 2`;
- floatField -edit
- -enterCommand ("setFocus " + $gTimeSliderTimeField)
- $gTimeSliderTimeField;
-
- // Create a grid layout for the play back buttons.
- //
- string $grid = `gridLayout
- -width 224
- -numberOfRowsColumns 1 8
- -cellWidthHeight 28 28`;
-
- // Create the play back buttons...
- //
- string $startButton = `symbolButton
- -image "timerew.xpm"
- -annotation "Go to start of playback range"
- -command "playButtonStart"`;
-
- string $stepBackButton = `symbolButton
- -image "timeend.xpm"
- -annotation "Step back one frame"
- -command "playButtonStepBackward"`;
-
- string $prevCmd = "currentTime -edit `findKeyframe -timeSlider -which previous`";
- string $prevButton = `symbolButton
- -image "timeprev.xpm"
- -annotation "Step back one key"
- -command $prevCmd`;
-
- $gPlayBackReverseButton = `symbolButton
- -image "timerev.xpm"
- -annotation "Play backwards. Pressing the ESC key will stop playback."
- -command "playButtonBackward"`;
-
- $gPlayBackForwardButton = `symbolButton
- -image "timeplay.xpm"
- -annotation "Play forwards. Pressing the ESC key will stop playback."
- -command "playButtonForward"`;
-
- string $nextCmd = "currentTime -edit `findKeyframe -timeSlider -which next`";
- string $nextButton = `symbolButton
- -image "timenext.xpm"
- -annotation "Step forward one key"
- -command $nextCmd`;
-
- string $stepFwdButton = `symbolButton
- -image "timestart.xpm"
- -annotation "Step forward one frame"
- -command "playButtonStepForward"`;
-
- string $endButton = `symbolButton
- -image "timefwd.xpm"
- -annotation "Go to end of playback range"
- -command "playButtonEnd"`;
-
- // Make attachments for contents of Time slider.
- //
- formLayout -edit
- -attachForm $timeFrame "top" 0
- -attachForm $timeFrame "left" 1
- -attachNone $timeFrame "bottom"
- -attachControl $timeFrame "right" 2 $gTimeSliderTimeField
-
- -attachForm $gTimeSliderTimeField "top" 5
- -attachNone $gTimeSliderTimeField "left"
- -attachNone $gTimeSliderTimeField "bottom"
- -attachControl $gTimeSliderTimeField "right" 2 $grid
-
- -attachForm $grid "top" 3
- -attachNone $grid "left"
- -attachNone $grid "bottom"
- -attachForm $grid "right" 0
- $timeSlider;
-
- // Attach Time slider to parent.
- //
- formLayout -edit
- -attachForm $timeSlider "top" 0
- -attachForm $timeSlider "left" 0
- -attachForm $timeSlider "bottom" 0
- -attachForm $timeSlider "right" 0
- $gTimeSliderForm;
-
- // Add call back to current time changes...
- //
- scriptJob -permanent -parent $timeSlider -event "timeChanged"
- ( "floatField -edit -value `currentTime -query` "
- + $gTimeSliderTimeField );
-
- // Add callbacks playback controls...
- //
- floatField -edit -value `currentTime -query`
- -changeCommand ("currentTime " +
- "`floatField -query -value "
- + $gTimeSliderTimeField + "`; " +
- "setFocus `paneLayout -query -pane1 viewPanes`;")
- $gTimeSliderTimeField;
-
- // Register sound scrub callbacks on the timeControl widget.
- //
- timeControl -e -pc "timeControl -e -beginScrub $gPlayBackSlider"
- -rc "timeControl -e -endScrub $gPlayBackSlider" $gPlayBackSlider;
-
- // Make sure the play controls are in synch with playback
- //
- condition -dependency playingBack
- -script playbackStateChanged playbackIconsCondition;
-
- // Attach a popup menu to the timeslider area
- //
- TimeSliderMenu($timeSlider);
-
- setUIComponentStateCallback(
- "Time Slider", "timeSliderVisibilityStateChange");
- }
-
- global proc int timeSliderVisibilityStateChange(
- int $newState,
- string $layout)
- //
- // Description:
- // This procedure is called whenever the visibility state of the
- // Time Slider is changed.
- //
- // Arguments:
- // newState - The new visibile state of the Time Slider.
- //
- // layout - The parent layout for the Time Slider.
- //
- // Returns:
- // true - If the change of state is to be allowed.
- //
- // false - If the state change is rejected.
- //
- {
- int $result = true;
-
- // Defer these commands because this proc is called when the visibility
- // state is about to change. This proc must return true to accept
- // the state change. After this proc returns then restore the
- // panel focus and update the pref menu.
- //
- evalDeferred("restoreLastPanelWithFocus(); updatePrefsMenu();");
-
- return $result;
- }
-